package servlet;

import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestAttributeEvent;
import javax.servlet.ServletRequestAttributeListener;
import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class SessionListener implements HttpSessionListener,
HttpSessionAttributeListener {

	@Override
	public void attributeAdded(HttpSessionBindingEvent arg0) {
		String name=arg0.getName();
		Object value=arg0.getValue();
		
		System.out.println("范围session内添加 name："+name+" 值为："+value+" 的属性");


	}

	@Override
	public void attributeRemoved(HttpSessionBindingEvent arg0) {
		String name=arg0.getName();
		Object value=arg0.getValue();
		System.out.println("范围session内 name："+name+" 值为："+value+" 的属性被移除了");

	}

	@Override
	public void attributeReplaced(HttpSessionBindingEvent arg0) {
		String name=arg0.getName();
		Object value=arg0.getValue();
		System.out.println("范围session内 name："+name+" 值为："+value+" 的属性被替换了");


	}

	@Override
	public void sessionCreated(HttpSessionEvent arg0) {
		HttpSession request=(HttpSession) arg0.getSession();

		System.out.println("--session-发向"+request.getId()+"的请求被销毁了");

	}

	@Override
	public void sessionDestroyed(HttpSessionEvent arg0) {
		HttpSession request=(HttpSession) arg0.getSession();
		System.out.println("--session-发向"+request.getId()+"的请求被初始化了");
		
	}

}
